
import Vue from 'vue'

Vue.filter('timeFormat', (value, flag) => {
    if (!value) return '';
    var str = '-';
    function toten(value) {
        return value < 10 ? '0' + value : value;
    }
    var time = new Date(value);
    var year = time.getFullYear()
    var month = time.getMonth() + 1;
    var day = time.getDate()
    var hour = time.getHours()
    var min = time.getMinutes()
    var sec = time.getSeconds()
    return flag ? (year + str + toten(month) + str + toten(day)) : (year + str + toten(month) + str + toten(day) + ' ' + toten(hour) + ":" + toten(min) + ":" + toten(sec))
})

Vue.filter('sexFormat', (value, str = '-') => {
    switch (value) {
        case '':
            return '未设置';
        case 1:
            return '女';
        case 2:
            return '男';

        default:
            return '未设置';
    }
})
